#pragma once
#include "SList.h"

//	//一般不会这样去创建链表，这里只是为了给大家展示链表的打印
//void SlistTest01()
//{
//	SLTNode* node1 = (SLTNode*)malloc(sizeof(SLTNode));
//	node1->data = 1;
//	SLTNode* node2 = (SLTNode*)malloc(sizeof(SLTNode));
//	node2->data = 2;
//	SLTNode* node3 = (SLTNode*)malloc(sizeof(SLTNode));
//	node3->data = 3;
//	SLTNode* node4 = (SLTNode*)malloc(sizeof(SLTNode));
//	node4->data = 4;
//
//	node1->next = node2;
//	node2->next = node3;
//	node3->next = node4;
//	node4->next = NULL;
//
//	SLTNode* plist = node1;
//	SLTPrint(plist);
//
//}

void SlistTest01()
{
	SLTNode* plist = NULL;
	SLTPushBack(&plist, 1);
	SLTPushBack(&plist, 2);
	SLTPushBack(&plist, 3);
	SLTPrint(plist); // 1->2->3->NULL

	SLTPushFront(&plist, 4); // 4->1->2->3->NULL
	SLTPrint(plist);

	SLTPopBack(&plist);
	SLTPopBack(&plist);
	SLTPrint(plist); // 4->1->NULL

}

void SlistTest03()
{
	SLTNode* plist = NULL;
	SLTPushBack(&plist, 1);
	SLTPushBack(&plist, 2);
	SLTPushBack(&plist, 3);
	SLTPrint(plist);

	// 头删
	SLTPopFront(&plist);
	SLTPopFront(&plist);
	SLTPrint(plist);

	//SLTNode* FindRet = SLTFind(&plist, 3);
	//if (FindRet) printf("找到了\n");
	//else printf("没找到\n");

	SLTInsert(&plist, plist, 1);
	SLTPrint(plist);

	SLTErase(&plist, plist);
	SLTPrint(plist);

	SListDesTroy(&plist);
}

int main()
{
	// SlistTest01();
	// SlistTest02();
	SlistTest03();

	return 0;
}